/*
 * by cansik / Florian
 * Datum: 06.05.2010
 * Zeit: 09:50
 * 
 *
 */
using System;
using System.Drawing;

namespace PixelReplacer
{
	/// <summary>
	/// A PixelRule defines the color filter values
	/// </summary>
	public class PixelRule
	{
        /// <summary>
        /// Name of the Rule
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// Filerdefinition for the Alpha channel
        /// </summary>
        public PixelRange A { get; set; }
        /// <summary>
        /// Filerdefinition for the Red channel
        /// </summary>
        public PixelRange R { get; set; }
        /// <summary>
        /// Filerdefinition for the Green channel
        /// </summary>
        public PixelRange G { get; set; }
        /// <summary>
        /// Filerdefinition for the Blue channel
        /// </summary>
        public PixelRange B { get; set; }

        /// <summary>
        /// If true, the colors will be mixed
        /// </summary>
        public bool AdaptColors { get; set; }
        /// <summary>
        /// The intense of mixing
        /// </summary>
        public int AdaptValue { get; set; }

        /// <summary>
        /// New Color for the Pixels
        /// </summary>
        public Color NewColor { get; set; }
		
        /// <summary>
        /// Creates a new Pixel Rule
        /// </summary>
		public PixelRule()
		{
			this.A = new PixelRange();
			this.R = new PixelRange();
			this.G = new PixelRange();
			this.B = new PixelRange();
		}
		
        /// <summary>
        /// Checks if the color das match with this PixelRule
        /// </summary>
        /// <param name="checkColor">Color to Check</param>
        /// <returns>True, if it matches</returns>
		public bool Match(Color checkColor)
		{
			return (this.A.IsBetween(checkColor.A) && this.R.IsBetween(checkColor.R) && this.G.IsBetween(checkColor.G) && this.B.IsBetween(checkColor.B));
		}

        /// <summary>
        /// Returns a String Output of the PixelRule
        /// </summary>
        /// <returns>Returns a String Output of the PixelRule</returns>
        public override string ToString()
        {
            return this.Name + "\n{\na(" + this.A.ToString() + ");\nr(" + this.R.ToString() + ");\ng(" + this.G.ToString() + ");\nb(" + this.B.ToString() + ");\ncolor(" + this.NewColor.A + ", " + this.NewColor.R + ", " + this.NewColor.G + ", " + this.NewColor.B + ");\nadapt=" + this.AdaptColors.ToString() + ";\n}";
        }
	}
}
